<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
                .box {
            width: 100px;
            height: 100px;
            background-color: wheat;
            border-radius: 12px;
            position: absolute;
            top: 10px;
            transition: all 2s;
        }
        button {
            position: relative;
            top: 300px;
        }
    </style>
</head>
<body>
    <div class="box" style="left:10px"></div>
    <button>按钮</button>
    <script>
        var box = document.querySelector('.box')
        var btn = document.querySelector('button')
        btn.onclick = function(){
        box.style.left = 300 + 'px'
        }
        console.log(box.style.left);
    </script>
</body>
</html>